<script>
  const graph = {
    0: [1, 2],
    1: [2],
    2: [0, 3],
    3: [3],
  }
  //深度优先遍历图
  const visited = new Set()
  const dfs = (n) => {
    console.log(n)
    visited.add(n)
    graph[n].forEach((e) => {
      if (!visited.has(e)) {
        dfs(e)
      }
    })
  }
  dfs(2)

</script>
